package com.cg.design.graphicdesignpattern.command.drawer;

import com.cg.design.graphicdesignpattern.command.command.Command;

import java.awt.*;

/**
 * @program: LeetCode->ColorCommand
 * @description: 表示“设置颜色的命令”的类，实现了Command接口
 * @author: cg
 * @create: 2022-04-05 19:50
 **/
public class ColorCommand implements Command {

    /**
     * 绘制对象
     */
    protected Drawable drawable;

    /**
     * 颜色
     */
    private final Color color;

    /**
     * 构造函数
     * @param drawable
     * @param color
     */
    public ColorCommand(Drawable drawable, Color color) {
        this.drawable = drawable;
        this.color = color;
    }

    @Override
    public void execute() {
        drawable.setColor(color);
    }
}
